package com.jwell.panrank.ui.activity

import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Bundle
import com.jwell.driverapp.ui.base.BaseActivity
import com.jwell.panrank.R
import com.jwell.panrank.entity.ElectronicePoundBean
import com.jwell.panrank.tools.StringUtils
import kotlinx.android.synthetic.main.activity_look_electronic_pound.*

class LookElectronicPoundActivity : BaseActivity() {
    private var data: ElectronicePoundBean? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        isSetPORTRAIT = false
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_look_electronic_pound)
        if (this.resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
            requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
        }
        intent?.extras?.let {
            data = it.getSerializable("data") as ElectronicePoundBean
        }
        data?.let {
            when (it.type) {
                2 -> {
                    initToolBar("空车计量", true, null)
                }
                1 -> {
                    initToolBar("重车计量", true, null)
                }
            }
            text_poundNum.text = "磅单号:" + (it.weightNo ?: "")
            text_sendCom.text = it.forwardingUnit ?: ""
            text_receiptCom.text = it.receivingUnit ?: ""
            text_goodsName.text = it.materialName ?: ""
            text_carNum.text = it.carNum ?: ""
            text_remark.text = it.emptY_CAR_REMARK ?: ""
            text_EMPTY_CAR_SERIAL_NUMBER.text = it.emptY_CAR_SERIAL_NUMBER ?: ""
            if (it.grossWt > 0) {//总重
                text_weight1.text = it.grossWt.toString() + "吨"
            }
            if (it.tareWt > 0) {//自重
                text_weight2.text = it.tareWt.toString() + "吨"
            }
            if (it.netWt > 0) {//净重
                text_weight3.text = it.netWt.toString() + "吨"
            }
            text_carMeasurePlace.text = it.carMeasurePlaceDescr ?: ""
            text_carMeasureTime.text = (StringUtils.getInstance()
                    .setModal(StringUtils.TIME_TYPE_3)
                    .regularization(it.carMeasureTime, "T", " "))
        }
    }
}

